package com.mingqijia.gassafety.shared.constant;

import org.apache.commons.lang3.StringUtils;

/**
 * 数据表种类代号
 */
public enum ExportCodeEnum {
    EXPORT_1_1("客户信息","EXPORT0001",1,"/inner/v1/export/consumerList",DataExporterConst.consumerTitles,DataExporterConst.consumerFields),
    EXPORT_1_2("客户信息","EXPORT0001",2,"/inner/v1/export/consumerList",DataExporterConst.asstConsumerTitles,DataExporterConst.asstConsumerFields),
    EXPORT_1_3("客户信息","EXPORT0001",3,"/inner/v1/export/consumerList",DataExporterConst.consumerServiceTitles,DataExporterConst.consumerServiceFields),
    EXPORT_2("实时监控","EXPORT0002",1,"/inner/v1/export/latestLogList",DataExporterConst.latestGasUserTitles,DataExporterConst.latestGasUserFields),
    EXPORT_3_1("燃气用户报警记录","EXPORT0003",1,"/inner/v1/export/alertLogList",DataExporterConst.AlertGasUserTitles,DataExporterConst.AlertGasUserFields),
    EXPORT_3_2("Vcc用户报警记录","EXPORT0003",2,"/inner/v1/export/alertLogList",DataExporterConst.AlertVccUserTitles,DataExporterConst.AlertVccUserFields),
    EXPORT_3_3("燃气用户报警记录","EXPORT0008",1,"/inner/v1/export/hangzhouAlertLogList",DataExporterConst.HangzhouAlertGasUserTitles,DataExporterConst.HangzhouAlertGasUserFields),
    EXPORT_3_4("Vcc用户报警记录","EXPORT0008",2,"/inner/v1/export/hangzhouAlertLogList",DataExporterConst.HangzhouAlertVccUserTitles,DataExporterConst.HangzhouAlertVccUserFields),
    EXPORT_4_1("燃气用户故障记录","EXPORT0004",1,"/inner/v1/export/brokenLogList",DataExporterConst.BrokenGasUserTitles,DataExporterConst.BrokenGasUserFields),
    EXPORT_4_2("Vcc用户故障记录","EXPORT0004",2,"/inner/v1/export/brokenLogList",DataExporterConst.BrokenVccUserTitles,DataExporterConst.BrokenVccUserFields),
    EXPORT_4_3("燃气用户故障记录","EXPORT0009",1,"/inner/v1/export/brokenLogList",DataExporterConst.BrokenGasUserTitles,DataExporterConst.BrokenGasUserFields),
    EXPORT_4_4("Vcc用户故障记录","EXPORT0009",2,"/inner/v1/export/brokenLogList",DataExporterConst.HangzhouBrokenVccUserTitles,DataExporterConst.HangzhouBrokenVccUserFields),
    EXPORT_5("设备列表","EXPORT0005",1,"/inner/v1/export/export",DataExporterConst.euquipmentTitles,DataExporterConst.euquipmentFields),
    EXPORT_6("账号列表","EXPORT0006",1,"/inner/v1/export/userList",DataExporterConst.userTitles,DataExporterConst.userFields),
    EXPORT_7("企业列表","EXPORT0007",1,"/inner/v1/export/companyList",DataExporterConst.companyTitles,DataExporterConst.companyFields),
    EXPORT_8("实时监控","EXPORT0002",2,"/inner/v1/export/latestLogList",DataExporterConst.latestVccUserTitles,DataExporterConst.latestVccUserFields),
    EXPORT_9("运行记录列表","EXPORT0010",1,"/inner/v1/export/running/list",DataExporterConst.runningRecordTitles,DataExporterConst.runningRecordFields),
    EXPORT_12("组织管理","EXPORT0012",1,"/inner/v1/export/organizationalDepartment",DataExporterConst.organizationalDepartmentRecordTitles,DataExporterConst.organizationalDepartmentFields),
    EXPORT_13("账号管理","EXPORT0013",1,"/inner/v1/export/accountNumber",DataExporterConst.accountNumberRecordTitles,DataExporterConst.accountNumberFields),
    PDF_1("运行报告","PDF0001",1,"/inner/v1/export/running/list",DataExporterConst.runningRecordTitles,DataExporterConst.runningRecordFields),
    EXPORT_11("企业管理","EXPORT0011",1,"/inner/v1/export/company/manage",DataExporterConst.companyRecordTitles,DataExporterConst.companyRecordFields),
    EXPORT_14("一次上报情况列表","EXPORT00014",1,"/inner/v1/export/one/report/list",DataExporterConst.oneReportListTitles,DataExporterConst.oneReportListFields),
    EXPORT_15("一次上报情况明细","EXPORT00015",1,"/inner/v1/export/one/report/detail",DataExporterConst.oneReportDetailTitles,DataExporterConst.oneReportDetailFields),
    EXPORT_16_1("设备上报情况","EXPORT0016",1,"/inner/v1/export/device/report/condition",DataExporterConst.deviceMonthReportDetailTitles,DataExporterConst.deviceMonthReportDetailFields),
    EXPORT_16_2("设备上报情况","EXPORT0016",2,"/inner/v1/export/device/report/condition",DataExporterConst.deviceMonthReportDetailTitlesThree,DataExporterConst.deviceMonthReportDetailFieldsThree),
    EXPORT_16_3("设备上报情况","EXPORT0016",3,"/inner/v1/export/device/report/condition",DataExporterConst.deviceMonthReportDetailTitleLeap,DataExporterConst.deviceMonthReportDetailFieldLeap),
    EXPORT_16_4("设备上报情况","EXPORT0016",4,"/inner/v1/export/device/report/condition",DataExporterConst.deviceMonthReportDetailTitle,DataExporterConst.deviceMonthReportDetailField),
    EXPORT_16_5("设备上报情况","EXPORT0016",5,"/inner/v1/export/device/report/condition",DataExporterConst.deviceYearReportDetailTitles,DataExporterConst.deviceYearReportDetailFields);

    private String name;

    private String code;

    private Integer templateType;

    private String url;

    private String[] titles;

    private String[] fields;
    private ExportCodeEnum(String name, String code, Integer templateType,String url, String[] titles, String[] fields) {
        this.name = name;
        this.code = code;
        this.url = url;
        this.titles = titles;
        this.fields = fields;
        this.templateType = templateType;
    }

    public void setTitles(String[] titles) {
        this.titles = titles;
    }

    public void setFields(String[] fields) {
        this.fields = fields;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public String getCode() {
        return this.code;
    }

    public String getUrl() {
        return this.url;
    }

    public String[] getTitles() {
        return this.titles;
    }

    public String[] getFields() {
        return this.fields;
    }

    public static ExportCodeEnum getExportCode(String exportCode, Integer templateType) {
        if (StringUtils.isBlank(exportCode) ||  templateType ==null) {
            return null;
        }
        for (ExportCodeEnum code : ExportCodeEnum.values()) {
            if (code.code.equalsIgnoreCase(exportCode) && code.templateType.equals(templateType)) {
                return code;
            }
        }
        return null;
    }

    /**
     * 导出表头信息更新
     * @param exportCodeEnum
     * @param fields
     * @param titles
     * @return
     */
    public static ExportCodeEnum updateExport(ExportCodeEnum exportCodeEnum,String[] fields ,String[] titles ){
        exportCodeEnum.setFields(fields);
        exportCodeEnum.setTitles(titles);
        return exportCodeEnum;
    }

}
